package cn.jbolt.core.poi.excel;

import cn.jbolt.core.util.JBoltDateUtil;
import com.jfinal.kit.StrKit;

import java.awt.*;
import java.util.Date;

/**
 * POI excel word水印
 *
 * @ClassName: JBoltWaterMark
 * @author: JFinal学院-小木 QQ：909854136
 * @date: 2021年9月16日
 *
 *        注意：本内容仅限于JFinal学院 JBolt平台VIP成员内部传阅，请尊重开发者劳动成果，不要外泄出去用于其它商业目的
 */
public class JBoltWaterMark {
	private String text;
	private Date date;
	private String dateFormat;
	private String color;
	private int width;
	private int height;
	private Font font;

	private JBoltWaterMark(String text) {
		this(text, null, null, "#999999");
	}

	private JBoltWaterMark(String text, int width, int height) {
		this(text, "#999999", width, height);
	}

	private JBoltWaterMark(String text, Date date) {
		this(text, date, JBoltDateUtil.YMDHMS);
	}

	private JBoltWaterMark(String text, Date date, int width, int height) {
		this(text, date, null, null, null, width, height);
	}

	private JBoltWaterMark(String text, Date date, String dateFormat) {
		this(text, date, dateFormat, null, null, 400, 200);
	}

	private JBoltWaterMark(String text, String color) {
		this(text, null, null, color);
	}

	private JBoltWaterMark(String text, Date date, String dateFormat, String color) {
		this(text, date, dateFormat, color, null, 400, 200);
	}

	private JBoltWaterMark(String text, String color, Font font) {
		this(text, null, null, color, font);
	}

	private JBoltWaterMark(String text, Date date, String dateFormat, String color, Font font) {
		this(text, date, dateFormat, color, font, 400, 200);
	}

	private JBoltWaterMark(String text, Date date, String color, int width, int height) {
		this(text, date, null, color, null, width, height);
	}

	private JBoltWaterMark(String text, Date date, String color, Font font) {
		this(text, date, null, color, font, 400, 200);
	}

	private JBoltWaterMark(String text, String color, int width, int height) {
		this(text, null, null, color, null, width, height);
	}

	private JBoltWaterMark(String text, String color, Font font, int width, int height) {
		this(text, null, null, color, font, width, height);
	}

	private JBoltWaterMark(String text, Date date, String dateFormat, String color, Font font, int width, int height) {
		this.text = StrKit.defaultIfBlank(text, "内部资料");
		this.date = date;
		this.dateFormat = StrKit.defaultIfBlank(dateFormat, JBoltDateUtil.YMDHMS);
		this.color = StrKit.defaultIfBlank(color, "#999999");
		if (font == null) {
			this.font = new Font("microsoft-yahei", Font.PLAIN, 24);
		} else {
			this.font = font;
		}
		this.width = width;
		this.height = height;
	}

	public String getText() {
		return text;
	}

	public void setText(String text) {
		this.text = text;
	}

	public String getDateFormat() {
		return dateFormat;
	}

	public void setDateFormat(String dateFormat) {
		this.dateFormat = dateFormat;
	}

	public String getColor() {
		return color;
	}

	public void setColor(String color) {
		this.color = color;
	}

	public Date getDate() {
		return date;
	}

	public void setDate(Date date) {
		this.date = date;
	}

	public int getWidth() {
		return width;
	}

	public void setWidth(int width) {
		this.width = width;
	}

	public int getHeight() {
		return height;
	}

	public void setHeight(int height) {
		this.height = height;
	}

	public Font getFont() {
		return font;
	}

	public void setFont(Font font) {
		this.font = font;
	}

	public static JBoltWaterMark create(String text) {
		return new JBoltWaterMark(text);
	}

	public static JBoltWaterMark create(String text, int width, int height) {
		return new JBoltWaterMark(text, width, height);
	}

	public static JBoltWaterMark create(String text, Date date) {
		return new JBoltWaterMark(text, date);
	}

	public static JBoltWaterMark create(String text, Date date, int width, int height) {
		return new JBoltWaterMark(text, date, width, height);
	}

	public static JBoltWaterMark create(String text, Date date, String dateFormat) {
		return new JBoltWaterMark(text, date, dateFormat);
	}

	public static JBoltWaterMark create(String text, String color) {
		return new JBoltWaterMark(text, color);
	}

	public static JBoltWaterMark create(String text, Date date, String dateFormat, String color) {
		return new JBoltWaterMark(text, date, dateFormat, color);
	}

	public static JBoltWaterMark create(String text, String color, Font font) {
		return new JBoltWaterMark(text, color, font);
	}

	public static JBoltWaterMark create(String text, Date date, String dateFormat, String color, Font font) {
		return new JBoltWaterMark(text, date, dateFormat, color, font);
	}

	public static JBoltWaterMark create(String text, Date date, String color, Font font) {
		return new JBoltWaterMark(text, date, color, font);
	}

	public static JBoltWaterMark create(String text, Date date, String color, int width, int height) {
		return new JBoltWaterMark(text, date, color, width, height);
	}

	public static JBoltWaterMark create(String text, String color, int width, int height) {
		return new JBoltWaterMark(text, color, width, height);
	}

	public static JBoltWaterMark create(String text, String color, Font font, int width, int height) {
		return new JBoltWaterMark(text, color, font, width, height);
	}

	public static JBoltWaterMark create(String text, Date date, String dateFormat, String color, Font font, int width,
			int height) {
		return new JBoltWaterMark(text, date, dateFormat, color, font, width, height);
	}

}
